#!/bin/bash
cd ~/webtin
WEBTIN_DEP=`pwd`
cd ~/build/webtin
WEBTIN_HOME=`pwd`
PLUGIN_FOLDER=plugins

if [ ! -d $WEBTIN_DEP/$PLUGIN_FOLDER ] ; then
	echo $WEBTIN_DEP/$PLUGIN_FOLDER
	mkdir $WEBTIN_DEP/$PLUGIN_FOLDER
fi

 for f in $WEBTIN_HOME/*; do
 	PLUGINS=$f
 	if [ "$PLUGINS" = "$WEBTIN_HOME/$PLUGIN_FOLDER" ]; then
 		for e in $PLUGINS/* ; do
 			PLUGIN=$e
 			BASE_NAME=`basename $PLUGIN`
 			if [ ! -d $WEBTIN_DEP/$PLUGIN_FOLDER/$BASE_NAME ] ; then
 				mkdir $WEBTIN_DEP/$PLUGIN_FOLDER/$BASE_NAME
 			fi
 			
 			for d in $PLUGIN/* ; do
 				if [ "$d" != "$PLUGIN/lasttime.dat" ];  then
 					cp $d $WEBTIN_DEP/$PLUGIN_FOLDER/$BASE_NAME
 				fi
 			done
 		done
 	fi
  done